package com.jyun;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class CountFilter implements Filter {
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
      HttpServletRequest request=(HttpServletRequest) servletRequest;
//        System.out.println(request.getHeader("WL-Proxy-Client-IP"));
        System.out.println("ip:"+servletRequest.getRemoteAddr()+";page:"+request.getRequestURL());
        HttpSession session=request.getSession(true);
        session.setAttribute("ip:",servletRequest.getRemoteAddr());
        session.setAttribute("path",request.getRequestURL());
        filterChain.doFilter(servletRequest, servletResponse);
    }

    public void destroy() {

    }
}
